package com.yoda.controller;
import com.yoda.dto.CatePageDTO;
import com.yoda.entity.YddCate;
import com.yoda.result.Result;
import com.yoda.service.IYddCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_cate")
public class YddCateController {

    @Autowired
    private IYddCateService iYddCateService;
    /**
     * 分类详情-根据id查询
     * @return
     */
    @GetMapping("/rowInfo")
    public Result getById(@RequestParam String id){
        return iYddCateService.getById(id);
    }

    /**
     * 分类列表-分页
     * @return
     */
    @GetMapping("/list")
    public Result  pageCate(CatePageDTO dto){
        return iYddCateService.pageCate(dto);
    }


    @GetMapping("/del")
    public Result delete(@RequestParam String id){
        iYddCateService.removeById(id);
        return Result.success();
    }

    /**
     * 修改分类
     * @param yddCate
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody YddCate yddCate){
        return iYddCateService.update(yddCate);
    }



    /**
     * 新增分类
     * @param yddCate
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody YddCate yddCate){

        return iYddCateService.add(yddCate);
    }


    /**
     * 分类列表
     * @return
     */
    @GetMapping("/all")
    public Result selectAll(){
        return iYddCateService.selectAll();
    }

}

